package com.dzzw.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/*
    待优化该工具类；
 */
public class DButils {

    public static final String DRIVER = "com.mysql.jdbc.Driver";//加载数据库驱动；

    public static final String URL = "jdbc:mysql://localhost:3306/dzzw?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true";//数据库链接；

    public static final String USER = "root"; //数据库用户名；

    public static final String PASSWORD = "123456";//数据库密码；

    public static Connection con = null;

    public static Connection getCon() {
        try {
            Class.forName(DRIVER);
            con = DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (ClassNotFoundException e) {
            System.out.println("数据库连接成功！");
            e.printStackTrace();
            System.out.println("数据库连接失败！");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }
}
